package xio.ccf_201503;
/*
 * ccf 201503-1 图像旋转 100分
 */

import java.util.Scanner;

public class ImageRotation {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] src = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				src[m-1-j][i] = sc.nextInt();
			}
		}
		
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(src[i][j]+" ");
			}
			System.out.println("");
		}
	}
}
